package com.wpml.netty.rpc.common;

import lombok.Builder;
import lombok.Data;
import lombok.ToString;

import java.io.Serializable;
import java.util.UUID;

/**
 * @Description 请求头信息
 * @Date 2021-05-06
 * @Author wangpei
 **/
@Data
@Builder
@ToString
public class MyHeader implements Serializable {

    int flag;  //32bit可以设置很多信息。。。
    long requestID;
    long dataLen;


    public static MyHeader createHeader(byte[] msg) {
        int size = msg.length;
        int f = 0x14141414;
        long requestID = Math.abs(UUID.randomUUID().getLeastSignificantBits());
        //0x14  0001 0100

        return MyHeader.builder()
                .flag(f)
                .dataLen(size)
                .requestID(requestID)
                .build();
    }
}
